package com.lzy.cloud.url.service.impl;

import com.lzy.cloud.url.dtos.ShortUrlDto;
import com.lzy.cloud.url.entity.ShortUrl;
import com.lzy.cloud.url.mapper.ShortUrlMapperExt;
import com.lzy.cloud.url.service.ShortUrlService;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShortUrlServiceImpl implements ShortUrlService {

    @Autowired
    private ShortUrlMapperExt shortUrlMapperExt;


    @Override
    public ShortUrlDto findByShortUrl(String url) {
        return shortUrlMapperExt.findByShortUrl(url);
    }

    @Override
    public ShortUrlDto findByUrl(String url) {
        return shortUrlMapperExt.findByUrl(url);
    }

    @Override
    public Long insert(ShortUrlDto shortUrlDto) {
        ShortUrl shortUrl = DozerUtils.map(shortUrlDto, ShortUrl.class);
        return shortUrlMapperExt.insertSelective(shortUrl) > 0 ? shortUrl.getId() : null;
    }

    @Override
    public int update(ShortUrlDto shortUrlDto) {
        return 0;
    }

    @Override
    public Boolean delete(Long aLong) {
        return null;
    }

    @Override
    public Boolean remove(Long aLong) {
        return null;
    }

    @Override
    public ShortUrlDto findById(Long aLong) {
        return null;
    }

    @Override
    public List<ShortUrlDto> query(Pager pager, ShortUrlDto shortUrlDto) {
        return null;
    }
}
